<?php
if($_REQUEST["f"]){
  try {
    $connection = ssh2_connect('172.20.1.123', 22, array('hostkey'=>'ssh-dss'));
    ssh2_auth_pubkey_file($connection, 'frontend',
      '/var/astolfo/.ssh/id_dsa.pub',
      '/var/astolfo/.ssh/id_dsa', '');
    if(ssh2_scp_send($connection, '/var/astolfo/web/uploads/'.$_REQUEST["f"], '/var/frontend/web/files/'.$_REQUEST["f"]))
      header("Location: http://cmais.com.br/files/".$_REQUEST["f"]."?complete=1");
    else
      header("Location: http://200.136.27.181/uploads/".$_REQUEST["f"]."?complete=0");
  } catch (Exception $e) {
    echo 'Error: ', $e->getMessage();
  }
}